package com.asset.salesforce.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.asset.salesforce.dao.ContactDaoImpl;
import com.asset.salesforce.domain.Contact;

@Service
@Transactional(readOnly=true)
public class ContactService {
	
	@Autowired
	private ContactDaoImpl contactDaoImpl;
	@Transactional(readOnly=false)
	public void addContact(Contact contact) {
		contactDaoImpl.add(contact);
	}
	@Transactional(readOnly=true)
	public Contact getContactById(Integer id) {
		return contactDaoImpl.getById(id, new Contact());
	}
	@Transactional(readOnly=true)
	public List<Contact>  getByImpID(Integer id) {
		 return contactDaoImpl.getAllContactByEmpId(id);
	}
	
	@Transactional(readOnly=true)
	public List<Contact> getContactByParent(String typeId, Integer parentId){
		return contactDaoImpl.getByParent(typeId, parentId);
	}
	
	@Transactional(readOnly=true)
	public List<Contact>  getAllContacts(Integer index) {
		 return contactDaoImpl.getAllContact(index);
	}
	
	@Transactional(readOnly=true)
	public List<Contact>  getAllContactsForCompany(Integer index,Integer companyName,Integer count) {
		 return contactDaoImpl.getAllContactForCompany(index, companyName,count);
	}
	
	@Transactional(readOnly=false)
	public void deleteContact(Integer id) {
		contactDaoImpl.deleteContact(id);
	}
	@Transactional(readOnly=false)
	public void saveOrUpdate(Contact contact) {
		contactDaoImpl.saveOrupdate(contact);
	}
	@Transactional(readOnly=true)
	public Integer getAllContactSize() {
		return contactDaoImpl.getAllContactSize();
	}
	
	@Transactional(readOnly=true)
	public Integer getAllContactForCompanySize(Integer companyName) {
		return contactDaoImpl.getAllContactForCompanySize(companyName);
	}
	
	
	@Transactional(readOnly=true)
	public List<Contact> getAllContactByEmpId(Integer empId){
		return contactDaoImpl.getAllContactByEmpId(empId);
	}
	@Transactional(readOnly=true)
	public Contact getContactByParentType( String typeId,Integer empId) {
		return contactDaoImpl.getContactByParent(typeId,empId);
	}
	
	@Transactional(readOnly=true)
	public List<Contact> getAllContactByName(String name,String companyName) {
		return contactDaoImpl.getAllContactByName(name,companyName);
	}
	@Transactional(readOnly=true)
	public List<Contact> getAllContactbyCompany(String companyName) {
		return contactDaoImpl.getAllContactbyCompany(companyName);
	}
	
	@Transactional(readOnly=true)
	public List<Contact> getAll(){
		return contactDaoImpl.getAll(new Contact());
	}

}
